/***********************************************************************
 * Module:  NarucenaUsluga.java
 * Author:  Igor Spremo, Milan Stojkov
 * Purpose: Defines the Class NarucenaUsluga
 ***********************************************************************/

package model.entity;

import java.io.Serializable;
import java.sql.Date;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

/**
 * 
 * @author Igor Spremo, Milan Stojkov
 *
 */

@SuppressWarnings("serial")
public class NarucenaUsluga implements Serializable {
	
	protected Integer id;
	protected int kolicinaNarucenihUsluga;
	protected String napomenaZaNarucenuUslugu;
	protected String linkNaFile;
	protected boolean izvrsena;
	protected Date datumZavrsetkaUsluge;
	protected int verzija;

	protected Collection<Saradnik> saradnici;

	
	
	public Collection<Saradnik> getSaradnici() {
		if (saradnici == null)
			saradnici = new HashSet<Saradnik>();
		
		return saradnici;
	}

	public Iterator<Saradnik> getIteratorSaradnici() {
		if (saradnici == null)
			saradnici = new HashSet<Saradnik>();
		
		return saradnici.iterator();
	}

	public void setSaradnici(Collection<Saradnik> newSaradnici) {
		removeAllSaradnici();
		for (Iterator<Saradnik> iter = newSaradnici.iterator(); iter.hasNext();)
			addSaradnik((Saradnik) iter.next());
	}

	public void addSaradnik(Saradnik newSaradnik) {
		if (newSaradnik == null)
			return;
		if (this.saradnici == null)
			this.saradnici = new HashSet<Saradnik>();
		if (!this.saradnici.contains(newSaradnik)) {
			this.saradnici.add(newSaradnik);
			newSaradnik.addNarucenaUsluga(this);
		}
	}

	public void removeSaradnik(Saradnik oldSaradnik) {
		if (oldSaradnik == null)
			return;
		if (this.saradnici != null)
			if (this.saradnici.contains(oldSaradnik)) {
				this.saradnici.remove(oldSaradnik);
				oldSaradnik.removeNarucenaUsluga(this);
			}
	}

	public void removeAllSaradnici() {
		if (saradnici != null) {
			Saradnik oldSaradnik;
			for (Iterator<Saradnik> iter = getIteratorSaradnici(); iter.hasNext();) {
				oldSaradnik = (Saradnik) iter.next();
				iter.remove();
				oldSaradnik.removeNarucenaUsluga(this);
			}
		}
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getKolicinaNarucenihUsluga() {
		return kolicinaNarucenihUsluga;
	}

	public void setKolicinaNarucenihUsluga(int kolicinaNarucenihUsluga) {
		this.kolicinaNarucenihUsluga = kolicinaNarucenihUsluga;
	}

	public String getNapomenaZaNarucenuUslugu() {
		return napomenaZaNarucenuUslugu;
	}

	public void setNapomenaZaNarucenuUslugu(String napomenaZaNarucenuUslugu) {
		this.napomenaZaNarucenuUslugu = napomenaZaNarucenuUslugu;
	}

	public String getLinkNaFile() {
		return linkNaFile;
	}

	public void setLinkNaFile(String linkNaFile) {
		this.linkNaFile = linkNaFile;
	}

	public boolean isIzvrsena() {
		return izvrsena;
	}

	public void setIzvrsena(boolean izvrsena) {
		this.izvrsena = izvrsena;
	}

	public Date getDatumZavrsetkaUsluge() {
		return datumZavrsetkaUsluge;
	}

	public void setDatumZavrsetkaUsluge(Date datumZavrsetkaUsluge) {
		this.datumZavrsetkaUsluge = datumZavrsetkaUsluge;
	}

	public int getVerzija() {
		return verzija;
	}

	public void setVerzija(int verzija) {
		this.verzija = verzija;
	}

}